package com.test.demo.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class RedisDao {

    @Autowired
    private StringRedisTemplate template;

    /**
     * 获取缓存中的值
     * @param key
     * @return
     */
    public String getKey(String key){
        return template.opsForValue().get(key);
    }

    public void setKey(String key,String value){
         template.opsForValue().set(key,value);
    }
}
